<?php

namespace app\api\controller;

use app\admin\model\Villageimages AS VillageimagesMdl;

/**
 * 村图片接口
 * Class Organization
 */
class Villageimages extends BaseController
{

    /**
     * 获取村图片 -- （Banner和列表）
     *
     * @return \think\response\Json
     */
    public function getImages()
    {
        $param = self::getHttpParam();

        $start = 0;
        $length = 20;
        if (empty($param->villageId)) {
            return show(config('status.ERROR_STATUS'), self::NOT_PARAM, 'villageId不能为空');
        }

        $where = [
            'villageId' => $param->villageId
        ];
        $fields = 'imgUrl';

        if (!empty($param->start)) {
            $start = $param->start;
        }
        if (!empty($param->length)) {
            $length = $param->length;
        }

        $result = VillageimagesMdl::where($where)->order('createDate DESC')->limit($start, $length)->field($fields)->select();
        $total = VillageimagesMdl::where($where)->count();

        if (empty($result)) {
            return show(config('status.ERROR_STATUS'), self::NOT_DATA, '未查到村图片');
        }

        return showTotal(config('status.SUCCESS_STATUS'), self::MSG_SUCCESS, $result, $total);
    }

    /**
     * 获取村图片 -- 列表显示
     *
     * @return \think\response\Json
     */
    /*public function getImageList()
    {
        //
    }*/
}